package com.kiln.juxingqs.ui

import android.view.View
import androidx.navigation.fragment.NavHostFragment
import com.kiln.juxingqs.BaseMiddleActivity
import com.kiln.juxingqs.R
import com.kiln.juxingqs.databinding.ActivityXyzrNewBinding
import com.kiln.juxingqs.ui.vm.XyzrNewViewModel

//我的竞拍 income_record接口,默认r_label参数

class XyzrNewActivity :
    BaseMiddleActivity<XyzrNewViewModel, ActivityXyzrNewBinding>() {

    var goods_id: String? = null
    var titleName: String? = null
    var detail_type: String? = null
    var isTabGone: Boolean = false

    override fun getLayout(): Int {
        return R.layout.activity_xyzr_new
    }

    override fun initViewModel(): XyzrNewViewModel = createViewModel()

    override fun initView() {
        binding.event = this
        binding.vm = viewModel
        goods_id = intent.getStringExtra("goods_id")
        titleName = intent.getStringExtra("titleName")
        detail_type = intent.getStringExtra("detail_type")
        detail_type?.let {
            isTabGone = it.equals("20") || it.equals("21") || it.equals("22") || it.equals("23")
        }

    }


    fun clickTab(index: Int) {
        updateTab(index)

    }

    fun updateTab(index: Int) {
        binding.two.visibility = View.VISIBLE
        binding.tvStatus.text="操作"
        when (index) {
            0 -> {
                binding.oneTab.isSelected = true
                binding.twoTab.isSelected = false
                binding.threeTab.isSelected = false
//                binding.one.visibility = View.VISIBLE

                binding.tvStatus.text="状态"
                (supportFragmentManager.findFragmentById(
                    R.id.fragment
                ) as NavHostFragment).navController.navigate(
                    R.id.oneTab
                )
            }
            1 -> {
                binding.oneTab.isSelected = false
                binding.twoTab.isSelected = true
                binding.threeTab.isSelected = false
//                binding.one.visibility = View.GONE
                (supportFragmentManager.findFragmentById(
                    R.id.fragment
                ) as NavHostFragment).navController.navigate(
                    R.id.twoTab
                )
            }
            2 -> {
                binding.oneTab.isSelected = false
                binding.twoTab.isSelected = false
                binding.threeTab.isSelected = true
//                binding.one.visibility = View.GONE

                (supportFragmentManager.findFragmentById(
                    R.id.fragment
                ) as NavHostFragment).navController.navigate(
                    R.id.threeTab
                )

            }
        }
    }

    override fun initData() {
        updateTab(intent.getIntExtra("index", 0))
    }

}